{
 "metadata": {
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.1-final"
  },
  "orig_nbformat": 2,
  "kernelspec": {
   "name": "python3",
   "display_name": "Python 3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2,
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "from pyecharts import options as opts\n",
    "from pyecharts.charts import Grid, Liquid\n",
    "from pyecharts.commons.utils import JsCode"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 124,
   "metadata": {},
   "outputs": [
    {
     "output_type": "stream",
     "name": "stderr",
     "text": [
      "C:\\Python3_7_2\\lib\\site-packages\\pyecharts\\charts\\chart.py:14: PendingDeprecationWarning: pyecharts 所有图表类型将在 v1.9.0 版本开始强制使用 ChartItem 进行数据项配置 :)\n  super().__init__(init_opts=init_opts)\nC:\\Python3_7_2\\lib\\site-packages\\pyecharts\\charts\\chart.py:14: PendingDeprecationWarning: pyecharts 所有图表类型将在 v1.9.0 版本开始强制使用 ChartItem 进行数据项配置 :)\n  super().__init__(init_opts=init_opts)\nC:\\Python3_7_2\\lib\\site-packages\\pyecharts\\charts\\chart.py:14: PendingDeprecationWarning: pyecharts 所有图表类型将在 v1.9.0 版本开始强制使用 ChartItem 进行数据项配置 :)\n  super().__init__(init_opts=init_opts)\nC:\\Python3_7_2\\lib\\site-packages\\pyecharts\\charts\\chart.py:14: PendingDeprecationWarning: pyecharts 所有图表类型将在 v1.9.0 版本开始强制使用 ChartItem 进行数据项配置 :)\n  super().__init__(init_opts=init_opts)\nC:\\Python3_7_2\\lib\\site-packages\\pyecharts\\charts\\chart.py:14: PendingDeprecationWarning: pyecharts 所有图表类型将在 v1.9.0 版本开始强制使用 ChartItem 进行数据项配置 :)\n  super().__init__(init_opts=init_opts)\nC:\\Python3_7_2\\lib\\site-packages\\pyecharts\\charts\\chart.py:14: PendingDeprecationWarning: pyecharts 所有图表类型将在 v1.9.0 版本开始强制使用 ChartItem 进行数据项配置 :)\n  super().__init__(init_opts=init_opts)\nC:\\Python3_7_2\\lib\\site-packages\\pyecharts\\charts\\chart.py:14: PendingDeprecationWarning: pyecharts 所有图表类型将在 v1.9.0 版本开始强制使用 ChartItem 进行数据项配置 :)\n  super().__init__(init_opts=init_opts)\nC:\\Python3_7_2\\lib\\site-packages\\pyecharts\\charts\\chart.py:14: PendingDeprecationWarning: pyecharts 所有图表类型将在 v1.9.0 版本开始强制使用 ChartItem 进行数据项配置 :)\n  super().__init__(init_opts=init_opts)\nC:\\Python3_7_2\\lib\\site-packages\\pyecharts\\charts\\chart.py:14: PendingDeprecationWarning: pyecharts 所有图表类型将在 v1.9.0 版本开始强制使用 ChartItem 进行数据项配置 :)\n  super().__init__(init_opts=init_opts)\nC:\\Python3_7_2\\lib\\site-packages\\pyecharts\\charts\\chart.py:14: PendingDeprecationWarning: pyecharts 所有图表类型将在 v1.9.0 版本开始强制使用 ChartItem 进行数据项配置 :)\n  super().__init__(init_opts=init_opts)\nC:\\Python3_7_2\\lib\\site-packages\\pyecharts\\charts\\chart.py:14: PendingDeprecationWarning: pyecharts 所有图表类型将在 v1.9.0 版本开始强制使用 ChartItem 进行数据项配置 :)\n  super().__init__(init_opts=init_opts)\nC:\\Python3_7_2\\lib\\site-packages\\pyecharts\\charts\\chart.py:14: PendingDeprecationWarning: pyecharts 所有图表类型将在 v1.9.0 版本开始强制使用 ChartItem 进行数据项配置 :)\n  super().__init__(init_opts=init_opts)\nC:\\Python3_7_2\\lib\\site-packages\\pyecharts\\charts\\chart.py:14: PendingDeprecationWarning: pyecharts 所有图表类型将在 v1.9.0 版本开始强制使用 ChartItem 进行数据项配置 :)\n  super().__init__(init_opts=init_opts)\nC:\\Python3_7_2\\lib\\site-packages\\pyecharts\\charts\\chart.py:14: PendingDeprecationWarning: pyecharts 所有图表类型将在 v1.9.0 版本开始强制使用 ChartItem 进行数据项配置 :)\n  super().__init__(init_opts=init_opts)\n"
     ]
    },
    {
     "output_type": "error",
     "ename": "TypeError",
     "evalue": "add() missing 1 required positional argument: 'data'",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mTypeError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-124-1a8cb3b89070>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m    348\u001b[0m \u001b[1;31m# grid = Grid(init_opts=opts.InitOpts(width=\"1400px\",height='250px')).add(mp, grid_opts=opts.GridOpts()).add(mod, grid_opts=opts.GridOpts()).add(mm, grid_opts=opts.GridOpts()).add(ani, grid_opts=opts.GridOpts()).add(env, grid_opts=opts.GridOpts()).add(lgt, grid_opts=opts.GridOpts()).add(efx1, grid_opts=opts.GridOpts()).add(efx2, grid_opts=opts.GridOpts()).add(comp1, grid_opts=opts.GridOpts()).add(comp2, grid_opts=opts.GridOpts()).add(mg, grid_opts=opts.GridOpts()).add(clip, grid_opts=opts.GridOpts()).add(clip, grid_opts=opts.GridOpts()).add(color, grid_opts=opts.GridOpts()).add(TD, grid_opts=opts.GridOpts())\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    349\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 350\u001b[1;33m all_=mp.add(mod).add(mm).add(ani).add(env).add(lgt).add(efx1).add(efx2).add(comp1).add(comp2).add(mg).add(clip).add(color).add(TD).set_global_opts(\n\u001b[0m\u001b[0;32m    351\u001b[0m                      graphic_opts=[ opts.GraphicText(\n\u001b[0;32m    352\u001b[0m                             graphic_item=opts.GraphicItem(\n",
      "\u001b[1;31mTypeError\u001b[0m: add() missing 1 required positional argument: 'data'"
     ]
    }
   ],
   "source": [
    "# mm = (\n",
    "#     #Liquid(init_opts={'page_title':'跟踪','width':'10px','height':'10px'})\n",
    "#     Liquid(init_opts=opts.InitOpts(width=\"10px\",height='10px'))\n",
    "#     .add(\"跟踪\", [0.6], center=[f\"{14*1}%\", \"30%\"],tooltip_opts= 'AAA')\n",
    "#     .set_global_opts(title_opts=opts.TitleOpts(title=\"多个 Liquid 显示\"),\n",
    "#                      graphic_opts=[ opts.GraphicText(\n",
    "#                             graphic_item=opts.GraphicItem(\n",
    "#                                 left=\"center\",\n",
    "#                                 top=\"middle\",\n",
    "#                                 z=100,),\n",
    "#                             graphic_textstyle_opts=opts.GraphicTextStyleOpts(\n",
    "#                                 # 可以通过jsCode添加js代码，也可以直接用字符串\n",
    "#                                 text=JsCode(\n",
    "#                                     \"['横轴表示数据类别',\"\n",
    "#                                     \"'纵轴表示数值的值',\"\n",
    "#                                     \"'这个文本块可以放在图中各',\"\n",
    "#                                     \"'种位置'].join('\\\\n')\"),\n",
    "#                                 #font=\"14px Microsoft YaHei\",\n",
    "#                                 graphic_basicstyle_opts=opts.GraphicBasicStyleOpts(\n",
    "#                                     fill=\"#333\")\n",
    "#                             )\n",
    "#                      )]\n",
    "#                      )\n",
    "# )\n",
    "\n",
    "mul=10\n",
    "y_p=27\n",
    "y_p1=73\n",
    "bias=5\n",
    "f_size=20\n",
    "mp =Liquid(init_opts=opts.InitOpts(width=\"20px\",height='2px')).add(\n",
    "    \"01美术\",\n",
    "    [0.3254],\n",
    "    center=[f\"{mul*1+bias}%\", f\"{y_p}%\"],\n",
    "    label_opts=opts.LabelOpts(\n",
    "        font_size=f_size,\n",
    "        formatter=JsCode(\n",
    "            \"\"\"function (param) {\n",
    "                    return (Math.floor(param.value * 10000) / 100) + '%';\n",
    "                }\"\"\"\n",
    "        ),\n",
    "        position=\"inside\",\n",
    "\n",
    "    ),\n",
    ").set_global_opts(title_opts=opts.TitleOpts(title=\"各部门达标率\"))\n",
    "\n",
    "\n",
    "mod = Liquid().add(\n",
    "    \"02模型\",\n",
    "    [0.3254],\n",
    "    center=[f\"{mul*2+bias}%\", f\"{y_p}%\"],\n",
    "    label_opts=opts.LabelOpts(\n",
    "        font_size=f_size,\n",
    "        formatter=JsCode(\n",
    "            \"\"\"function (param) {\n",
    "                    return (Math.floor(param.value * 10000) / 100) + '%';\n",
    "                }\"\"\"\n",
    "        ),\n",
    "        position=\"inside\",\n",
    "    ),\n",
    ")\n",
    "\n",
    "mm = Liquid().add(\n",
    "    \"03跟踪\",\n",
    "    [0.3254],\n",
    "    center=[f\"{mul*3+bias}%\", f\"{y_p}%\"],\n",
    "    label_opts=opts.LabelOpts(\n",
    "        font_size=f_size,\n",
    "        formatter=JsCode(\n",
    "            \"\"\"function (param) {\n",
    "                    return (Math.floor(param.value * 10000) / 100) + '%';\n",
    "                }\"\"\"\n",
    "        ),\n",
    "        position=\"inside\",\n",
    "    ),\n",
    ")\n",
    "\n",
    "ani = Liquid().add(\n",
    "    \"04动画\",\n",
    "    [0.3254],\n",
    "    center=[f\"{mul*4+bias}%\", f\"{y_p}%\"],\n",
    "    label_opts=opts.LabelOpts(\n",
    "        font_size=f_size,\n",
    "        formatter=JsCode(\n",
    "            \"\"\"function (param) {\n",
    "                    return (Math.floor(param.value * 10000) / 100) + '%';\n",
    "                }\"\"\"\n",
    "        ),\n",
    "        position=\"inside\",\n",
    "    ),\n",
    ")\n",
    "\n",
    "env = Liquid().add(\n",
    "    \"05场景\",\n",
    "    [0.3254],\n",
    "    center=[f\"{mul*5+bias}%\", f\"{y_p}%\"],\n",
    "    label_opts=opts.LabelOpts(\n",
    "        font_size=f_size,\n",
    "        formatter=JsCode(\n",
    "            \"\"\"function (param) {\n",
    "                    return (Math.floor(param.value * 10000) / 100) + '%';\n",
    "                }\"\"\"\n",
    "        ),\n",
    "        position=\"inside\",\n",
    "    ),\n",
    ")\n",
    "\n",
    "lgt = Liquid().add(\n",
    "    \"06灯光\",\n",
    "    [0.3254],\n",
    "    center=[f\"{mul*6+bias}%\", f\"{y_p}%\"],\n",
    "    label_opts=opts.LabelOpts(\n",
    "        font_size=f_size,\n",
    "        formatter=JsCode(\n",
    "            \"\"\"function (param) {\n",
    "                    return (Math.floor(param.value * 10000) / 100) + '%';\n",
    "                }\"\"\"\n",
    "        ),\n",
    "        position=\"inside\",\n",
    "    ),\n",
    ")\n",
    "\n",
    "efx1 = Liquid().add(\n",
    "    \"07特效一\",\n",
    "    [0.3254],\n",
    "    center=[f\"{mul*7+bias}%\", f\"{y_p}%\"],\n",
    "    label_opts=opts.LabelOpts(\n",
    "        font_size=f_size,\n",
    "        formatter=JsCode(\n",
    "            \"\"\"function (param) {\n",
    "                    return (Math.floor(param.value * 10000) / 100) + '%';\n",
    "                }\"\"\"\n",
    "        ),\n",
    "        position=\"inside\",\n",
    "    ),\n",
    ")\n",
    "\n",
    "efx2 = Liquid().add(\n",
    "    \"07特效二\",\n",
    "    [0.3254],\n",
    "    center=[f\"{mul*1}%\",  f\"{y_p1}%\"],\n",
    "    label_opts=opts.LabelOpts(\n",
    "        font_size=f_size,\n",
    "        formatter=JsCode(\n",
    "            \"\"\"function (param) {\n",
    "                    return (Math.floor(param.value * 10000) / 100) + '%';\n",
    "                }\"\"\"\n",
    "        ),\n",
    "        position=\"inside\",\n",
    "    ),\n",
    ")\n",
    "\n",
    "comp1 = Liquid().add(\n",
    "    \"08合成一\",\n",
    "    [0.3254],\n",
    "    center=[f\"{mul*2}%\", f\"{y_p1}%\"],\n",
    "    label_opts=opts.LabelOpts(\n",
    "        font_size=f_size,\n",
    "        formatter=JsCode(\n",
    "            \"\"\"function (param) {\n",
    "                    return (Math.floor(param.value * 10000) / 100) + '%';\n",
    "                }\"\"\"\n",
    "        ),\n",
    "        position=\"inside\",\n",
    "    ),\n",
    ")\n",
    "\n",
    "comp2 = Liquid().add(\n",
    "    \"08合成二\",\n",
    "    [0.3254],\n",
    "    center=[f\"{mul*3}%\", f\"{y_p1}%\"],\n",
    "    label_opts=opts.LabelOpts(\n",
    "        font_size=f_size,\n",
    "        formatter=JsCode(\n",
    "            \"\"\"function (param) {\n",
    "                    return (Math.floor(param.value * 10000) / 100) + '%';\n",
    "                }\"\"\"\n",
    "        ),\n",
    "        position=\"inside\",\n",
    "    ),\n",
    ")\n",
    "\n",
    "mg = Liquid().add(\n",
    "    \"09包装\",\n",
    "    [0.3254],\n",
    "    center=[f\"{mul*4}%\", f\"{y_p1}%\"],\n",
    "    label_opts=opts.LabelOpts(\n",
    "        font_size=f_size,\n",
    "        formatter=JsCode(\n",
    "            \"\"\"function (param) {\n",
    "                    return (Math.floor(param.value * 10000) / 100) + '%';\n",
    "                }\"\"\"\n",
    "        ),\n",
    "        position=\"inside\",\n",
    "    ),\n",
    ")\n",
    "\n",
    "\n",
    "clip = Liquid().add(\n",
    "    \"10剪辑\",\n",
    "    [0.3254],\n",
    "    center=[f\"{mul*5}%\", f\"{y_p1}%\"],\n",
    "    label_opts=opts.LabelOpts(\n",
    "        font_size=f_size,\n",
    "        formatter=JsCode(\n",
    "            \"\"\"function (param) {\n",
    "                    return (Math.floor(param.value * 10000) / 100) + '%';\n",
    "                }\"\"\"\n",
    "        ),\n",
    "        position=\"inside\",\n",
    "    ),\n",
    ")\n",
    "\n",
    "color = Liquid().add(\n",
    "    \"11调色\",\n",
    "    [0.3254],\n",
    "    center=[f\"{mul*6}%\", f\"{y_p1}%\"],\n",
    "    label_opts=opts.LabelOpts(\n",
    "        font_size=f_size,\n",
    "        formatter=JsCode(\n",
    "            \"\"\"function (param) {\n",
    "                    return (Math.floor(param.value * 10000) / 100) + '%';\n",
    "                }\"\"\"\n",
    "        ),\n",
    "        position=\"inside\",\n",
    "    ),\n",
    ")\n",
    "\n",
    "TD = Liquid().add(\n",
    "    \"12TD\",\n",
    "    [0.9254],\n",
    "    center=[f\"{mul*7}%\", f\"{y_p1}%\"],\n",
    "    # color= [\"#FF0000\", \"#FF4500\", \"#FF7F00\", \"#ffa345\"],\n",
    "    #color= [\"#FF7F00\", \"#ffa345\"],\n",
    "    # color = \"#FF0000\",\n",
    "    # color = \"#FF7F00\",\n",
    "    # outline_itemstyle_opts={'color':\"#FF7F00\"},\n",
    "    label_opts=opts.LabelOpts(\n",
    "        font_size=f_size,\n",
    "        # color='#fafafa',\n",
    "        formatter=JsCode(\n",
    "            \"\"\"function (param) {\n",
    "                    return (Math.floor(param.value * 10000) / 100) + '%';\n",
    "                }\"\"\"\n",
    "        ),\n",
    "        position=\"inside\",\n",
    "    )\n",
    ")\n",
    "\n",
    "\n",
    "# TD = Liquid().add(\n",
    "#     \"12TD\",\n",
    "#     [0.9254],\n",
    "#     center=[f\"{mul*7}%\", f\"{y_p1}%\"],\n",
    "#     # color= [\"#FF0000\", \"#FF4500\", \"#FF7F00\", \"#ffa345\"],\n",
    "#     #color= [\"#FF7F00\", \"#ffa345\"],\n",
    "#     # color = \"#FF0000\",\n",
    "#     # color = \"#FF7F00\",\n",
    "#     # outline_itemstyle_opts={'color':\"#FF7F00\"},\n",
    "#     label_opts=opts.LabelOpts(\n",
    "#         font_size=f_size,\n",
    "#         # color='#fafafa',\n",
    "#         formatter=JsCode(\n",
    "#             \"\"\"function (param) {\n",
    "#                     return (Math.floor(param.value * 10000) / 100) + '%';\n",
    "#                 }\"\"\"\n",
    "#         ),\n",
    "#         position=\"inside\",\n",
    "#     )\n",
    "# ) .set_global_opts(\n",
    "#             # title_opts=opts.TitleOpts(title=\"Bar-Graphic Rect+Text 2 组件示例\"),\n",
    "#             graphic_opts=[\n",
    "#                 opts.GraphicGroup(\n",
    "#                     graphic_item=opts.GraphicItem(\n",
    "#                         # 控制整体的位置\n",
    "#                         left=\"10%\",\n",
    "#                         top=\"5%\",\n",
    "#                     ),\n",
    "#                     children=[\n",
    "#                         # opts.GraphicRect控制方框的显示\n",
    "#                         # 如果不需要方框，去掉该段即可\n",
    "#                         opts.GraphicRect(\n",
    "#                             graphic_item=opts.GraphicItem(\n",
    "#                                 z=100,\n",
    "#                                 left=\"center\",\n",
    "#                                 top=\"middle\",\n",
    "#                             ),\n",
    "#                             graphic_shape_opts=opts.GraphicShapeOpts(\n",
    "#                                 width=190, height=90,\n",
    "#                             ),\n",
    "#                             graphic_basicstyle_opts=opts.GraphicBasicStyleOpts(\n",
    "#                                 fill=\"#fff\",\n",
    "#                                 stroke=\"#555\",\n",
    "#                                 line_width=2,\n",
    "#                                 shadow_blur=8,\n",
    "#                                 shadow_offset_x=3,\n",
    "#                                 shadow_offset_y=3,\n",
    "#                                 shadow_color=\"rgba(0,0,0,0.3)\",\n",
    "#                             )\n",
    "#                         ),\n",
    "#                         # opts.GraphicText控制文字的显示\n",
    "#                         opts.GraphicText(\n",
    "#                             graphic_item=opts.GraphicItem(\n",
    "#                                 left=\"center\",\n",
    "#                                 top=\"middle\",\n",
    "#                                 z=100,\n",
    "#                             ),\n",
    "#                             graphic_textstyle_opts=opts.GraphicTextStyleOpts(\n",
    "#                                 # 可以通过jsCode添加js代码，也可以直接用字符串\n",
    "#                                 # text=\"AAAAAAAAAAAAA\",\n",
    "#                                 # font=\"14px Microsoft YaHei\",\n",
    "#                                 text=JsCode(\n",
    "#                                     \"['横轴表示数据类别',\"\n",
    "#                                     \"'纵轴表示数值的值',\"\n",
    "#                                     \"'这个文本块可以放在图中各',\"\n",
    "#                                     \"'种位置'].join('\\\\n')\"\n",
    "#                                 ),\n",
    "#                                 graphic_basicstyle_opts=opts.GraphicBasicStyleOpts(\n",
    "#                                     fill=\"#333\"\n",
    "#                                 )\n",
    "#                             )\n",
    "#                         )\n",
    "#                     ]\n",
    "#                 )\n",
    "#             ],\n",
    "#         )\n",
    "\n",
    "\n",
    "\n",
    "# v = Liquid().add(\n",
    "#     \"13虚拟\",\n",
    "#     [0.3254],\n",
    "#     center=[\"25%\", \"50%\"],\n",
    "#     label_opts=opts.LabelOpts(\n",
    "#         font_size=10,\n",
    "#         formatter=JsCode(\n",
    "#             \"\"\"function (param) {\n",
    "#                     return (Math.floor(param.value * 10000) / 100) + '%';\n",
    "#                 }\"\"\"\n",
    "#         ),\n",
    "#         position=\"inside\",\n",
    "#     ),\n",
    "# )\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "# grid = Grid(init_opts=opts.InitOpts(width=\"1400px\",height='250px')).add(mp, grid_opts=opts.GridOpts()).add(mod, grid_opts=opts.GridOpts()).add(mm, grid_opts=opts.GridOpts()).add(ani, grid_opts=opts.GridOpts()).add(env, grid_opts=opts.GridOpts()).add(lgt, grid_opts=opts.GridOpts()).add(efx1, grid_opts=opts.GridOpts()).add(efx2, grid_opts=opts.GridOpts()).add(comp1, grid_opts=opts.GridOpts()).add(comp2, grid_opts=opts.GridOpts()).add(mg, grid_opts=opts.GridOpts()).add(clip, grid_opts=opts.GridOpts()).add(clip, grid_opts=opts.GridOpts()).add(color, grid_opts=opts.GridOpts()).add(TD, grid_opts=opts.GridOpts())\n",
    "\n",
    "all_=mp.add(mod).add(mm).add(ani).add(env).add(lgt).add(efx1).add(efx2).add(comp1).add(comp2).add(mg).add(clip).add(color).add(TD).set_global_opts(\n",
    "                     graphic_opts=[ opts.GraphicText(\n",
    "                            graphic_item=opts.GraphicItem(\n",
    "                                left=\"center\",\n",
    "                                top=\"middle\",\n",
    "                                z=100,),\n",
    "                            graphic_textstyle_opts=opts.GraphicTextStyleOpts(\n",
    "                                # 可以通过jsCode添加js代码，也可以直接用字符串\n",
    "                                text=JsCode(\n",
    "                                    \"['横轴表示数据类别',\"\n",
    "                                    \"'纵轴表示数值的值',\"\n",
    "                                    \"'这个文本块可以放在图中各',\"\n",
    "                                    \"'种位置'].join('\\\\n')\"),\n",
    "                                font=\"14px Microsoft YaHei\",\n",
    "                                graphic_basicstyle_opts=opts.GraphicBasicStyleOpts(\n",
    "                                    fill=\"#333\")\n",
    "                            )\n",
    "                     )]\n",
    "                     )\n",
    "\n",
    "all_.render(\"department_liquid.html\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ]
}